﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.DataAnnotations.Schema;
#if !NETFX_CORE
using System.Data.Entity;
#endif
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Entry;
using Cofe.Core.EntryType;
using Cofe.Core.Implements;
using Cofe.Data;

namespace Cofe.IO.Implements
{
#if !NETFX_CORE
    [Export(typeof(ICofeService))]
    [ServicePriority(ServicePriorityAttribute.DefaultPriority_COFEIO)]
    public class EFFileSystemInfoConfig : IDatabaseConfigurator
    {
        public void OnDatabaseCreating(CofeDbContext context)
        {
        }

        public void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var cofeSystemInfoConfig = modelBuilder.Entity<CofeSystemInfo>();
            var fileInfoConfig = modelBuilder.Entity<FileInfo>();

            cofeSystemInfoConfig.Map<FileInfo>(m =>
            {
                //m.MapInheritedProperties();
                m.Requires("Discriminator").HasValue(Cofe.IO.FileTypes.File);
                m.ToTable("FileInfo");
            });

            cofeSystemInfoConfig.Map<DirectoryInfo>(m =>
            {
                //m.MapInheritedProperties();
                m.Requires("Discriminator").HasValue(Cofe.IO.FileTypes.Folder);
                m.ToTable("DirectoryInfo");
            });





        }
    }
#endif
}
